<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="zh" xml:lang="zh"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://xmlns.jcp.org/jsf/passthrough">
<ui:composition template="templates/common.xhtml">
	<ui:define name="pageTitle">#{labels.appName}</ui:define>
	<ui:define name="mainContents">
		<div class="row">
			<div class="large-10 large-centered columns">
				<nav class="breadcrumbs">
					<h:outputLink value="index.html">#{labels.commonMenuGlance}</h:outputLink>
					<h:outputLink value="#{'#'}" styleClass="unavailable">#{labels.commonMenuVenue}</h:outputLink>
					<h:outputLink value="#{'#'}" styleClass="current">#{labels.commonMenuAdminManage}</h:outputLink>
				</nav>
			</div>
		</div>
		<div class="row">
			<div class="large-11 large-centered columns">
				<div class="row">
					<h:form id="admin_man_form">
						<div class="large-4 large-offset-2 columns">
							<fieldset>
								<legend>#{labels.adminManageAdmin}</legend>
								<div class="row collapse">
									<div class="large-9 columns">
										<h:inputText id="search" value="#{administratorFormBean.searchKeyword}"
										             p:placeholder="#{labels.adminManageAdminSearch}"/>
									</div>
									<div class="large-3 columns">
										<h:commandButton value="#{labels.formSearch}" styleClass="button postfix"
										                 action="#{adminBean.searchAdmins}">
											<f:ajax execute="search" render="admins"/>
										</h:commandButton>
									</div>
								</div>
								<h:selectOneListbox id="admins" style="background: none; height: 100%;" size="18"
								                    value="#{administratorFormBean.selectedAdmin}"
								                    valueChangeListener="#{administratorSelectBean.loadAdminDetail}">
                                    <f:selectItem itemLabel="#{labels.formAddContent}" itemValue="new_content"/>
									<f:selectItems value="#{administratorsBean.admins}" var="admin"
                                                   itemLabel="#{admin.name}" itemValue="#{admin.workdId}"/>
									<f:ajax render="@form"/>
								</h:selectOneListbox>
							</fieldset>
						</div>
						<div class="large-4 columns">
							<fieldset>
								<legend>#{administratorFormBean.addMode?labels.adminManageAdminAdd:labels.adminManageAdminModify}</legend>
								<div class="row">
									<div class="large-12 columns">
										<h:outputLabel for="adminworkid" value="#{labels.adminManageAdminWorkId}"/>
										<h:inputText id="adminworkid" value="#{administratorFormBean.adminWorkId}" required="true"
										             requiredMessage="#{labels.adminManageWorkIdRequired}"
                                                     validator="#{adminBean.validateWorkId}"
                                                     validatorMessage="#{labels.adminManageWorkIdUnusable}"
										             onkeyup="realtimeUpcase();"/>
										<h:message for="adminworkid" fatalClass="alert-box alert"
										           errorClass="alert-box alert"
										           warnClass="alert-box warning" infoClass="alert-box info"/>
									</div>
									<div class="large-12 columns">
										<h:outputLabel for="adminname" value="#{labels.adminManageAdminName}"/>
										<h:inputText id="adminname" value="#{administratorFormBean.adminName}"/>
									</div>
									<div class="large-12 columns">
										<h:outputLabel for="adminpass" value="#{labels.adminManageAdminPassword}"/>
										<h:inputSecret id="adminpass" value="#{administratorFormBean.adminPassword}"/>
									</div>
									<div class="large-12 columns">
										<h:outputLabel value="#{labels.adminManageAdminRole}"/>
										<h:selectOneMenu value="#{administratorFormBean.selectedRole}">
											<f:selectItems value="#{rolesBean.roles}" var="role"
                                                           itemLabel="#{role.role}" itemValue="#{role.svrid}"/>
										</h:selectOneMenu>
									</div>
									<div class="large-12 columns">
										<h:selectBooleanCheckbox id="admindisabled" value="#{administratorFormBean.adminDisabled}"/>
										<h:outputLabel for="admindisabled" value="#{labels.adminManageAdminDisable}"/>
									</div>
								</div>
								<ul class="button-group even-3">
									<li>
										<h:commandButton value="#{labels.formRemove}" styleClass="button small alert"
										                 action="#{adminBean.removeAdministrator}"
										                 onclick="return confirm('#{labels.adminManageConfirmDelete}');">
											<f:ajax execute="admins" render="@form"/>
										</h:commandButton>
									</li>
									<li>
										<h:commandButton value="#{labels.formSave}" styleClass="button small"
										                 action="#{adminBean.saveAdministrator}">
											<f:ajax execute="@form" render="@form"/>
										</h:commandButton>
									</li>
									<li>
										<h:commandButton value="#{labels.formReset}" type="reset"
										                 styleClass="button small secondary"/>
									</li>
								</ul>
							</fieldset>
						</div>
						<h:inputHidden id="addMode" value="#{administratorFormBean.addMode}"/>
					</h:form>
				</div>
			</div>
		</div>
	</ui:define>
	<ui:define name="javascriptFunctions">
		<h:outputScript library="scripts" name="adminman.js" target="body"/>
	</ui:define>
</ui:composition>
</html>
